<?php
namespace app\index\controller;
use think\Session;
use think\Controller;
use think\Db;
class Cases extends Controller{
    public function Add(){
        if (session("login")!=1) return $this->error("请先登录");
        if (isset($_POST["add"])) {
            if($_POST["needrevisit"]=="true")
            db('customer')->where("id",input("id"))->setField("lastdate",$_POST["revisitdate"]);
            $add=[
                "uid"=>input("id"),
                "yid"=>input("yid"),
                "date"=>date("Y-m-d"),
                "content"=>$_POST['casecontent'],
                "ask"=>$_POST['ask'],
                "prescription"=>$_POST['prescription'],
                "clinic"=>session('cid'),
            ];
            $result=db('case')->insertGetId($add);
            if($result) return $this->success('添加成功');
            else return $this->error('添加失败');
        }
        $customer=db('customer')->field("name,tel")->where("id",input("id"))->find();
        $this->assign("c",$customer);
        return view("add");
    }




}